@extends('admin.common.main')

@section('cnt')
@endsection
    <body>
    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-sm-4">
            <ol class="breadcrumb">
                <li>
                    <a href="index.html">主页</a>
                </li>
                <li>
                    <strong>房源管理</strong>
                </li>
            </ol>
        </div>
    </div>
    {{-- 消息提示 --}}
    @include('admin.common.msg')
        <form action="{{route('admin.fangattr.store')}}" method="post" enctype="multipart/form-data"  class="form-horizontal">
            @csrf
            <div class="form-group">
                <label class="col-sm-2 control-label">是否顶级：</label>
                <div class="col-sm-10">
                        <select name="pid" class="form-control selectpicker"
                                data-live-search="true" data-size="8">
                            <option value="0">--顶级菜单--</option>
                            @foreach($data as $val)
                                <option value="{{$val['id']}}">{{$val['name']}}</option>
                            @endforeach
                        </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">属性名称：</label>
                <div class="col-sm-10">
                    <input type="text" name="name" class="form-control"> <span class="help-block m-b-none"></span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">属性图标：</label>
                <div class="col-sm-10">
                    <input type="file" name="icon" id="imgMark" class="form-control" value=""><br/>
                    <img id="imgPre" src="" height="100px" class="img-rounded" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">字段名称：</label>
                <div class="col-sm-10">
                    <input type="text" name="field_name" class="form-control"> <span class="help-block m-b-none"></span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-10">
                    <input class="btn btn-primary radius" type="submit" value="提交">
                </div>
            </div>
            <div class="hr-line-dashed"></div>
        </form>
@section('js')
    <script type="text/javascript">
        function preImg(sourceId, targetId) {
            if (navigator.userAgent.indexOf("MSIE")>=1) {
                url = document.getElementById(sourceId).value;
            } else if(navigator.userAgent.indexOf("Firefox")>0) {
                url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
            } else if(navigator.userAgent.indexOf("Chrome")>0) {
                url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
            }
            document.getElementById(targetId).src = url;
        }
        $("#imgMark").on('change', function(){
            preImg('imgMark','imgPre');
        })
    </script>
    </body>
@endsection
